const app=getApp()
Page({
  data:{
    avatar:'',
    nickName:''
  },
  onLoad(){
    app.token&&this.getUserProfile()
  },
  goLogin() {
    wx.navigateTo({
      url: '/pages/login/index',
    })
  },
  async getUserProfile(){
    const {code,data:{avatar,nickName}}=await wx.http.get('/userInfo')
    if(code!==10000)return wx.utils.toast()
      this.setData({nickName,avatar})
      app.userProfile = {avatar, nickName}
  }
})
